  <template #default>
  <div id="labreportitemRefer">
    <vxe-toolbar perfect>
      <template #buttons>
        <vxe-textarea v-model="itemForm.itemFormula" placeholder="" resize="vertical" :autosize="{ minRows: 2, maxRows: 8 }" style="margin-top:5px;"></vxe-textarea>
      </template>
    </vxe-toolbar>
    <Splitpanes>
      <Pane size="72">
        <vxe-toolbar perfect>
          <template #buttons>
            <vxe-button type="text" class="button-blue" icon="vxe-icon-square-plus" content="确定" @click="addItemRules"></vxe-button>
            <vxe-button type="text" icon="vxe-icon-delete" class="button-red" content="取消" @click="closeItemRules"></vxe-button>
          </template>
        </vxe-toolbar>
        <div style="height:calc(100% - 40px)">
          <vxe-table ref="specialRuleTabRef" show-overflow auto-resize height="auto" :row-config="{isCurrent:true}" :data="bacDescOptionList" @cell-click="specialRuleRowClick">
            <vxe-column type="seq" title="#" width="50"></vxe-column>
            <vxe-column field="proResultNo" title="项目编码" width="100"></vxe-column>
            <vxe-column field="proResultNa" title="项目名称" width="200">
            </vxe-column>
            <vxe-column field="inputCode" title="英文缩写"></vxe-column>
          </vxe-table>
        </div>
      </Pane>
      <Pane size="28">
        <el-row>
          <vxe-button type="text" class="button-blue" content="+" @click="resulthandle('+')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="-" @click="resulthandle('-')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="*" @click="resulthandle('*')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="/" @click="resulthandle('/')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button type="text" class="button-blue" content=">" @click="resulthandle('>')"></vxe-button>
          <vxe-button type="text" class="button-blue" content=">=" @click="resulthandle('>=')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="<" @click="resulthandle('<')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="<=" @click="resulthandle('<=')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button type="text" class="button-blue" content="(" @click="resulthandle('(')"></vxe-button>
          <vxe-button type="text" class="button-blue" content=")" @click="resulthandle(')')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="AND" @click="resulthandle('&&')"></vxe-button>
          <vxe-button type="text" class="button-blue" content="OR" @click="resulthandle('||')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="年龄" @click="resulthandle('[年龄]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 数值结果" @click="resulthandle('[任意项目 数值结果]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="性别" @click="resulthandle('[性别]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 文字结果" @click="resulthandle('[任意项目 文字结果]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="病人类型" @click="resulthandle('[病人类型]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 危急值标志" @click="resulthandle('[任意项目 危急值标志]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="科室" @click="resulthandle('[科室]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 复查标志" @click="resulthandle('[任意项目 复查标志]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="标本类型" @click="resulthandle('[标本类型]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 结果标志" @click="resulthandle('[任意项目 结果标志]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="标本状态备注" @click="resulthandle('[标本状态备注]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目 仪器报警" @click="resulthandle('[任意项目 仪器报警]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="报告单备注" @click="resulthandle('[报告单备注]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="任意项目代码" @click="resulthandle('[任意项目代码]')"></vxe-button>
        </el-row>
        <el-row>
          <vxe-button style="width:100px" type="text" class="button-blue" content="诊断" @click="resulthandle('[诊断]')"></vxe-button>
          <vxe-button style="width:140px" type="text" class="button-blue" content="诊断CD10" @click="resulthandle('[诊断CD10]')"></vxe-button>
        </el-row>
      </Pane>
    </Splitpanes>
  </div>
</template>

<script lang="ts" setup>
// 引入组件区 ==========
import { ref, reactive, onMounted, getCurrentInstance, watch, defineProps } from 'vue';
import { VXETable } from 'vxe-table';
import { VxeMessage, VxeNotifyType } from '../../../utils/CommonMessage';
import { AppStore } from '../../../stores/store';
import { Splitpanes, Pane } from 'splitpanes';
import formulaTools from '../../../components/FormulaTools.vue';
import { IsEmpty } from '@/utils/common';
import LogInfo from '@/components/LogInfo.vue';
import VxeDictSelection from '@/components/VxeDictSelection.vue';
//import { ar } from 'element-plus/es/locale';

// 全局变量定义区 ==========
let iloading = ref(false); //按钮刷新状态
let itemForm = reactive({
  itemFormula: '',
  itemFormulaExplain: ''
}); /**特殊规则表单对象 */
let itemFormRef = ref(null); /**特殊规则表单Ref对象 */
let specRulesTableList = reactive([]); /**特殊规则列表 */
let specialRuleTabRef = ref(null); /**特殊规则列表对象 */

// 方法定义区 =============
defineExpose({ initPage });
let store = AppStore();
let { proxy }: any = getCurrentInstance();
let saveLoading = ref(false); //保存
let bacDescOptionList = reactive([]);

let tableList = reactive([]);
let loading = ref(false);

onMounted(() => {
  //ToDo
  findBacDescOptionList();
});

function resulthandle(result) {
  itemForm.itemFormula = (itemForm.itemFormula ? itemForm.itemFormula : '') + result;
}
function specialRuleRowClick({ row }) {
  itemForm.itemFormula = (itemForm.itemFormula ? itemForm.itemFormula : '') + '[' + row.proResultNo + ']';
}

function addItemRules() {
  proxy.$emit('addItemRules', itemForm.itemFormula);
}

function closeItemRules() {
  proxy.$emit('closeItemRules');
}

//左侧列表点击之后传来的值
function initPage(result: any) {
  itemForm.itemFormula = result;
}
//继续培养
function findBacDescOptionList() {
  bacDescOptionList.length = 0;
  const url = '/bac-cul-pro-result/findBacDescOptionList';
  proxy.$http
    .get(url)
    .then((res: any) => {
      if (res && res.data && res.data.length >= 0) {
        bacDescOptionList.push(...res.data);
      }
    })
    .catch((err: any) => {});
}
</script>
<style lang="scss" scoped>
#labreportitemRefer {
  width: 100%;
  height: 80%;

  .horizontalLine {
    :deep(.splitpanes__splitter) {
      background-color: $base-white;
    }
  }

  // 附加按钮间距
  .button-blue {
    min-width: 50px;
    margin-left: 20px;
  }
  .button-red {
    margin: 5px 0 5px 5px;
  }
  .el-row {
    margin-top: 10px;
  }

  .tableBody {
    height: calc(100% - 40px);
  }
}
</style>